package 上课day1;

import java.util.Iterator;
import java.util.LinkedList;

public class project_demo2 {
	public static void main(String[] args) {
		
		LinkedList<Student> linkedList = new LinkedList<>();
		
		Student stu1 = new Student(11, "张三");
		Student stu2 = new Student(12, "李四");
		Student stu3 = new Student(13, "王五");
		Student stu4 = new Student(14, "刘柳");
		Student stu5 = new Student(15, "李琦");
		
		Student stu6 = new Student(16, "王八");
		
		linkedList.add(stu1);
		linkedList.add(stu2);
		linkedList.add(stu3);
		linkedList.add(stu4);
		linkedList.add(stu5);
		
		linkedList.addFirst(stu6);
		
		linkedList.remove(3);
		
		//get遍历
		for (int i = 0; i < linkedList.size(); i++) {
			Student student = linkedList.get(i);
			System.out.println(student.getName() + "*************" + student.getAge());
		}
		System.out.println("---------------------------------------------------------");
		//Iterator 迭代器遍历
		Iterator<Student> it = linkedList.iterator();
		while (it.hasNext()) {
			Student student = it.next();
			System.out.println(student.getName() + "*************" + student.getAge());
		}
	}
}
